import axios from '../AxiosConfig.js'

//{"pattern":"^amq.", "definition": {"federation-upstream-set":"all"}, "priority":0, "apply-to": "all"}
export const createPolicy = data => {
  return axios({
    method: 'put',
    url: '/api/policies/' + encodeURIComponent(data.vhost) +'/' + data.name,
    data: data
  })
}

export const deletePolicy = (vhost, name) => {
  return axios({
    method: 'delete',
    url: '/api/policies/' + encodeURIComponent(vhost) +'/' + name,
  })
}

export const selectPolicy = (vhost, name) => {
  return axios({
    method: 'get',
    url: '/api/policies/' + encodeURIComponent(vhost) +'/' + name,
  })
}

export const listPolicy = () => {
  return axios({
    method: 'get',
    url: '/api/policies'
  })
}

export const listPolicyByVhost = (vhost) => {
  return axios({
    method: 'get',
    url: '/api/policies/' + encodeURIComponent(vhost)
  })
}

